package experiments;

/**
 * @authors Owen Phelan
 *-------------------------------------------------------------------
 * Preferences.java: Subsystem in charge of allowing the user to edit different 
 * properties of the computer simulator.
 *------------------------------------------------------------------
 */

public class Preferences {

	/**
	 * Invariants which ensure certain values
	 * for variables
	 */
	
	//@ invariant numALU > 0;
	//@ invariant CPUInstructionTime > 0;
	//@ invariant instructionMax > 0;
	//@ invariant SystemStatus !=false;
	//@ invariant RAMSize > 0;
	//@ invariant RAMSpeed > 0;
	//@ invariant TextSize > 8;
	//@ invariant TextSize < 72;
	//@ invariant InstructionSetSpeed > 0;
	//@ invariant InstructionSetType > 0;
	//@ invariant L2Status != false;
	//@ invariant L1CacheSize > 0;
	//@ invariant L2CacheSize > 0;
	//@ invariant L1CacheSpeed > 0;
	//@ invariant L2CacheSpeed > 0;
	
//-------------------------------------------------------------------------------------------
//                Preferences Fields
//-------------------------------------------------------------------------------------------
	
	//System Wide Field
	/**
	 * This will determine if the Computer Simulator
	 * is running, as to satisfy the constraint that the
	 * computer cannot be running if someone wants to modify
	 * anything in the preferences pane.
	 */
	private  boolean SystemStatus;
	
	/**
	 * This will be a button included within the PreferencesGUI.java
	 * Pane. It will return the Systems Preferences to Default Values
	 * I have made it a boolean as if the user clicks a GUI Button, it 
	 * returns a true value for the system to return the default values.
	 */
	private boolean SystemDefault;
	
//-------------------------------------------------------------------------------------------
//CPU Fields
	/**
	 * Time taken for each instruction to be executed.
	 */	

	private  int CPUInstructionTime;

	
	/**
	 * Number of ALU's present in the CPU.
	 */	
	private  int numALU;
	
	/**
	 * Maximum number of istuctions that can be carried
	 * out at any particular time.
	 */	
	private  int instructionMax;
	
//-------------------------------------------------------------------------------------------
//Monitoring Fields
	
	/**
	 * Monitoring status of CPU
	 * i.e. is CPU being monitored by monitoring sub-system
	 */
	private  boolean CPUMonitoringStatus;
	
	/**
	 * Monitoring status of RAM
	 * i.e. is RAM being monitored by monitoring sub-system
	 */
	private  boolean RAMMonitoringStatus;
	
	/**
	 * Monitoring status of Cache
	 * i.e. is cache being monitored by monitoring sub-system
	 */
	private  boolean cacheMonitoringStatus;
	
	/**
	 * Monitoring status of Instruction Set
	 * i.e. is Istruction set being monitored by 
	 * monitoring sub-system
	 */
	private  boolean instructionSetMonitoringStatus;
	
//-------------------------------------------------------------------------------------------
//Cache Fields
	
	/**
	 * This will hold the boolean variable which determines
	 * if the L2 is Enabled
	 */
	private  boolean L2Status;
	
	/**
	 * This will hold the integer variable which will 
	 * get the size of the L1 Cache
	 */
	private  int L1CacheSize;
	
	/**
	 * This will hold the integer variable which will
	 * get the size of the L2 Cache
	 */
	private  int L2CacheSize;
	
	/**
	 * This will hold the integer variable which will
	 * get the speed of the L1 Cache
	 */
	private  int L1CacheSpeed;

	/**
	 * This will hold the integer variable which will
	 * get the speed of the L2 Cache
	 */
	private  int L2CacheSpeed;
	
//-------------------------------------------------------------------------------------------
//Instruction Set Fields
	
	/**
	 * This will hold the integer variable which will
	 * get the speed of the Instruction Set
	 */
	private  int InstructionSetSpeed;
	
	/**
	 * This will hold the integer variable which will
	 * get the type of the Instruction Set
	 */ 
	private  int InstructionSetType;

//-------------------------------------------------------------------------------------------
//RAM Fields
	
	/**
 	* This will hold the variable which tells us
 	* the size of the RAM.
 	*/
	private  int ramSize;
	
	/**
	 * This will hold the variable which tells us
	 * the speed of the RAM.
	 */
	private  int ramSpeed;
	
//-------------------------------------------------------------------------------------------
//Main GUI Fields
	
	/**
	 * This will hold the variable which tells us
	 * the size of the text.
	 */
	private  int textSize;
	
		
	/**
	 * This will hold the variable which tells us
	 * the colour of the text.
	 */
	private  String textColour;
	
	/**
	 * These 3 variables hold the int values of the
	 * red, green and blue color values
	 */
	private int textRed;
	private int textGreen;
	private int textBlue;
	
	/**
	 * This will hold the variable which tells us
	 * the colour of the background.
	 */		
	private  String bgColour;
	
	/**
	 * This will hold the variable which tells us
	 * what image is in the background.
	 */
	private  String bgImage;
	
//-------------------------------------------------------------------------------------------
//Text I/O Fields
	
	/**
	 * Returns whether the TEXT I/O log is enabled
	 */
	private boolean isTextIOEnabled;
	
//-------------------------------------------------------------------------------------------
//Reporting Fields
	
	/**
	 * Report status of CPU
	 */
	private  boolean CPUReportStatus;
	
	/**
	 * Report status of RAM
	 */
	private  boolean RAMReportStatus;
	
	/**
	 * Report status of Cache
	 */
	private  boolean CacheReportStatus;
	
	/**
	 * Report status of Instruction Set
	 */
	private  boolean InstructionSetReportStatus;
	
//-------------------------------------------------------------------------------------------
//Permanent Storage Fields
	
	/**
	 * Permanent storage speed
	 */
	private int PermanentStorageSpeed;
	
	/**
	 * Permanent storage capacity
	 */
	private int PermanentStorageCapacity;
	
//-------------------------------------------------------------------------------------------

	/**
	 * The following associates the above variables with 
	 * the Preferences Method, and creates a new Preferences Object
	 */
	
	public Preferences(boolean CPUMon,boolean RAMMon,boolean CacheMon,boolean ISMon,int instrMax,int InTime,int aluCount,int ramSz,int ramSp,int l1size, int l2size, int l1speed, int l2speed, boolean CPURep,boolean RAMRep,boolean CacheRep,boolean ISRep,String bgCol,int textSz,int r,int g,int b, boolean l2stat, boolean textiostat,String bgImg,int PSSpeed, int PSCap,int ISSpeed, int ISType){
		this.CPUMonitoringStatus=CPUMon;
		this.RAMMonitoringStatus=RAMMon;
		this.cacheMonitoringStatus=CacheMon;
		this.instructionSetMonitoringStatus=ISMon;
		this.instructionMax = instrMax;
		this.CPUInstructionTime = InTime;
		this.numALU = aluCount;
		this.ramSize = ramSz;
		this.ramSpeed = ramSp;
		this.L1CacheSize=l1size;
		this.L2CacheSize=l2size;
		this.L1CacheSpeed=l1speed;
		this.L2CacheSpeed=l2speed;
		this.L2Status=l2stat;
		this.isTextIOEnabled=textiostat;
		this.CPUReportStatus=CPURep;
		this.RAMReportStatus=RAMRep;
		this.CacheReportStatus=CacheRep;
		this.InstructionSetReportStatus=ISRep;
		this.bgColour = bgCol;
		this.textSize = textSz;
		this.textRed = r;
		this.textGreen = g;
		this.textBlue = b;
		this.bgImage = bgImg;
		this.PermanentStorageSpeed = PSSpeed;
		this.PermanentStorageCapacity = PSCap;
		this.InstructionSetSpeed = ISSpeed;
		this.InstructionSetType = ISType;
	}
	
	public Preferences(){}
	
//-------------------------------------------------------------------------------------------
// Preferences Queries
//-------------------------------------------------------------------------------------------
//System wide query
	
	/**
	 * System Status Variable mentioned above will be implemented here
	 * It is needed as the Computer Simulator itself cannot be running while 
	 */
	
	public  boolean isSimOperating(){
		return SystemStatus;
	}

//-------------------------------------------------------------------------------------------
//CPU preferences queries
	
	/**
	 * Method which retrieves and returns CPUInstuctionTime
	 * @return CPUInstuctionTime
	 */
	public  int getCPUInstructionTime(){
		return CPUInstructionTime;
	}
	
	/**
	 * Method which retrieves and returns numALU
	 * @return numALU
	 */
	public int getNumALU(){
		return this.numALU;
	}
	
	/**
	 * Method which retrieves and returns instructionMax
	 * @return instructionMax
	 */
	public  int getInstructionMax(){
		int i = instructionMax;
		return i;
	}
	
//-------------------------------------------------------------------------------------------
//Monitoring queries
	
	/**
	 * Method which retrieves and returns weather cpu
	 * is being monitored or not.
	 * @return CPUMonitorStatus
	 */
	public  boolean getCPUMonitorStatus(){
		boolean b=CPUMonitoringStatus;
		return b;
	}
	
	/**
	 * Method which retrieves and returns weather RAM
	 * is being monitored or not
	 * @return RAMMonitoringStatus
	 */
	public  boolean getRAMMonitoringStatus(){
		boolean b = RAMMonitoringStatus;
		return b;
	}
	
	/**
	 * Method which retrieves and returns weather Cache
	 * is being monitored or not
	 * @return CacheMonitoringStutus
	 */
	public  boolean getCacheMonitoringStatus(){
		boolean b = cacheMonitoringStatus;
		return b;
	}
	
	/**
	 * Method which retrieves and returns weather instuction
	 * set is being monitored or not
	 * @return InstructionSetMonitoringStatus
	 */
	public  boolean getInstructionSetMonitoringStatus(){
		boolean b = instructionSetMonitoringStatus;
		return b;
	}
	
//-------------------------------------------------------------------------------------------
//Cache Queries
	public  boolean isL2Enabled(){
		return L2Status;
	}

	/**
	 * This method will retrieve the Size
	 * of the L1 Cache.
	 * @return L1CacheSize
	 */
	public  int getL1CacheSize(){
		return L1CacheSize;
	}
     
	/**
	 * This method will retrieve the Size
	 * of the L2 Cache.
	 * @return L2CacheSize
	 */
	public  int getL2CacheSize(){
		return L2CacheSize;
	}

	/**
	 * This method will retrieve the Speed
	 * of the L1 Cache.
	 * @return L1CacheSpeed
	 */
	public  int getL1CacheSpeed(){
		return L1CacheSpeed;
	}

	/**
	 * This method will retrieve the Speed
	 * of the L2 Cache.
	 * @return L2CacheSpeed
	 */
	public  int getL2CacheSpeed(){
		return L2CacheSpeed;
	}
	
//-------------------------------------------------------------------------------------------
//Instruction Set queries	
	
	/** 
	 * This will retrieve the SPEED of the Instruction Set
	 * @return InstructionSetSpeed
	 */
	public  int getInstructionSetSpeed(){
		int i = InstructionSetSpeed;
		return i;
	}
	
	/**
	 * This will retrieve the TYPE of the Instruction Set
	 * @return InstructionSetType
	 */
	public  int getInstructionSetType(){
		int i = InstructionSetType;
		return i;
	}
//-------------------------------------------------------------------------------------------
	
	//Text I/O Query
	/**
	 * The getTextIOStatus() boolean will 
	 * return the status of the Text I/O
	 * Log. It will then enable or disable this log
	 */
	public boolean getTextIOStatus()
	{
		return isTextIOEnabled;
	}

//-------------------------------------------------------------------------------------------
//RAM Queries
	/**
	 * This method will return the size
	 * of the RAM.
	 * @return ramSize
	 */
	public  int getRAMSize(){
		int i = ramSize;
		return i;
	}

	/**
	 * This method will return the
	 * speed of the RAM.
	 * @return ramSpeed
	 */
	public  int getRAMSpeed(){
		int i = ramSpeed;
		return i;
	}
	
//-------------------------------------------------------------------------------------------
//Main GUI Queries
	/**
	 * This method will return the
	 * size of the text.
	 * @return textSize
	 */
	public  int getTextSize(){
		int i = textSize;
		return i;
	}
	
	/**
	 * This method will return the
	 * colour of the text.
	 * @return textColour
	 */
	public  String getTextColour(){
		String c = textColour;
		return c;
	}
	
	/**
	 * This method will return the value
	 * of the red colour component
	 * @return textRed
	 */
	public int getTextRed(){
		int r = textRed;
		return r;
	}
	
	/**
	 * This method will return the value
	 * of the green colour component
	 * @return textGreen
	 */
	public int getTextGreen(){
		int g = textGreen;
		return g;
	}
	
	/**
	 * This method will return the value
	 * of the blue colour component
	 * @return textBlue
	 */
	public int getTextBlue(){
		int b = textBlue;
		return b;
	}
	
	/**
	 * This method will return the
	 * colour of the background.
	 * @return bgColour
	 */
	public  String getBGColour(){
		String c = bgColour;
		return c;
	}
	
	/**
	 * This method will return the
	 * image in the background.
	 * @return bgImage
	 */
	public  String getBGImage(){
		String s = bgImage;
		return s;
	}
	
	
//-------------------------------------------------------------------------------------------
//Reporting queries
	
	/**
	 * Method which retrieves and returns weather cpu
	 * is being reported or not.
	 * @return CPUReportStatus
	 */
	public  boolean getCPUReportStatus(){
		boolean r = CPUReportStatus;
		return r;
	}
	
	/**
	 * Method which retrieves and returns weather RAM
	 * is being reported or not
	 * @return RAMReportStatus
	 */
	public  boolean getRAMReportStatus(){
		boolean r = RAMReportStatus;
		return r;
	}
	
	/**
	 * Method which retrieves and returns weather Cache
	 * is being reported or not
	 * @return CacheReportStutus
	 */
	public  boolean getCacheReportStatus(){
		boolean r = CacheReportStatus;
		return r;
	}
	
	/**
	 * Method which retrieves and returns weather instuction
	 * set is being reported or not
	 * @return InstructionSetReportStatus
	 */
	public  boolean getInstructionSetReportStatus(){
		boolean r = InstructionSetReportStatus;
		return r;
	}
	
//-------------------------------------------------------------------------------------------
//Permanent Storage Queries
	
	/**
	 * Method which retrieves and returns the speed of the Permanent Storage
	 * @return PermanentStorageSpeed
	 */
	public int getPermanentStorageSpeed(){
		int p = PermanentStorageSpeed;
		return p;
	}
	
	/**
	 * Method which retrieves and returns the capacity of the Permanent Storage
	 * @return PermanentStorageCapacity
	 */
	public int getPermanentStorageCapacity(){
		int p = PermanentStorageCapacity;
		return p;
	}
	

//-------------------------------------------------------------------------------------------
//                Preferences Commands
//-------------------------------------------------------------------------------------------
// CPU
	
	/**
	 * Method which sets user defined CPU Instruction Time
	 * @param User defined or default time to execute
	 *        individual instructions.
	 */
	public  void setCPUInstructionTime(int instructionTime){
		CPUInstructionTime=instructionTime;
	}
	
	/**
	 * Method which sets user defined number of ALU's
	 * @param User defined number of ALU's present in CPU
	 */
	public  void setNumALU(int ALU){
		numALU=ALU;
	}

  	/**
  	 * Method which sets user defined maximum number
  	 * of instructions to be executed at any given
  	 * time by the CPU
  	 * @param Maximum number of instructions executed
  	 *        at a given time
  	 */
  	public  void setInstructionMax(int instructMax){
  		instructionMax=instructMax;
  	}
  	
  	/**
  	 * Method which sets monitoring status of CPU
  	 * CPU will be monitored or not
  	 * @param Status of CPU monitoring
  	 */
  	public  void setCPUmonitorStatus(boolean CPUMon){
  		CPUMonitoringStatus=CPUMon;
  	}
  	
  	/**
  	 * Method which sets monitoring status of RAM
  	 * RAM will be monitored or not
  	 * @param Status of RAM Monitoring
  	 */
  	public  void setRAMMonitoringStatus(boolean RAMMon){
  		RAMMonitoringStatus=RAMMon;
  	}
  	
  	/**
  	 * Method which sets monitoring status of Cache
  	 * Cache will be monitored or not
  	 * @param Status of cache monitoring
  	 */
  	public  void setCacheMonitoringStutus(boolean cacheMon){
  		cacheMonitoringStatus=cacheMon;
  	}
  	
  	/**
  	 * Method which sets monitoring status of Instuction
  	 * set. Instruction set will be monitored or not
  	 * @param status of instruction set monitoring.
  	 */
	public  void setInstructionSetMonitoringStatus(boolean instructMon){
		instructionSetMonitoringStatus=instructMon;
	}
	
//-------------------------------------------------------------------------------------------
// Cache Commands
	
	/**
	 * This will Enable the L2 Cache
	 * @param isL2Enabled
	 */
	public  void setL2Enabled(boolean L2Enab){
		L2Status=L2Enab;
	}
	
	/**
	 * This will set the SIZE of the L1 Cache
	 * @param L1CacheSize
	 */
	public  void setL1CacheSize(int L1Size){
		L1CacheSize=L1Size;
	}
	
	/**
	 * This will set the SIZE of the L2 Cache
	 * @param L2CacheSize
	 */
	public  void setL2CacheSize(int L2Size){
		L2CacheSize=L2Size;
	}
	
	/**
	 * This will set the SPEED of the L1 Cache
	 * @param L1CacheSpeed
	 */
	public  void setL1CacheSpeed(int L1Speed){
		L1CacheSpeed=L1Speed;
	}
	
	/**
	 * This will set the SPEED of the L2 Cache
	 * @param L2CacheSpeed
	 */
	public  void setL2CacheSpeed(int L2Speed){
		L2CacheSpeed=L2Speed;
	}
//-------------------------------------------------------------------------------------------
//RAM Commands
	
	/**
	* Method which allows user to set
	* the size of the RAM.
	*/
	public  void setRAMSize(int size){
		ramSize = size;
	}
	
	/**
	 * Method which allows the user to 
	 * set the speed of the RAM.
	 */
	public  void setRAMSpeed(int speed){
		ramSpeed = speed;
	}
//-------------------------------------------------------------------------------------------
//Main GUI Commands
	
	/**
	 * Method which allows user to set
	 * the size of the text.
	 */
	public  void setTextSize(int size){
		textSize = size;
	}
	
	/**
	 * Method which allows user to set
	 * the colour of the text.
	 */
	public  void setTextColour(String colour){
		textColour = colour;
	}
	
	/**
	 * Method which allows the user to set
	 * the value of the red component of the text colour
	 */
	public void setTextRed(int red){
		textRed = red;
	}
	
	/**
	 * Method which allows the user to set
	 * the value of the green component of the text colour
	 */
	public void setTextGreen(int green){
		textGreen = green;
	}
	
	/**
	 * Method which allows the user to set
	 * the value of the blue component of the text colour
	 */
	public void setTextBlue(int blue){
		textBlue = blue;
	}
	
	/**
	 * Method which allows user to set
	 * the colour of the background.
	 */
	public  void setBGColour(String colour){
		bgColour = colour;
	}
	
	/**
	 * Method which allows user to set
	 * the image in the background.
	 */
	public  void setBGImage(String image){
		bgImage = image;
	}	
//-------------------------------------------------------------------------------------------
//Reporting
	
	/**
  	 * Method which sets report status of CPU
  	 * CPU will be reported or not
  	 * @param Status of CPU report.
  	 */
  	public  void setCPUReportStatus(boolean CPURep){
  		CPUReportStatus=CPURep;
  	}
  	
  	/**
  	 * Method which sets report status of RAM
  	 * RAM will be reported or not
  	 * @param Status of RAM report.
  	 */
  	public  void setRAMReportStatus(boolean RAMRep){
  		RAMReportStatus=RAMRep;
  	}
  	
  	/**
  	 * Method which sets report status of Cache
  	 * Cache will be reported or not
  	 * @param Status of cache report.
  	 */
  	public  void setCacheReportStatus(boolean cacheRep){
  		CacheReportStatus=cacheRep;
  	}
  	
  	/**
  	 * Method which sets report status of Instuction
  	 * set. Instruction set will be reported or not
  	 * @param status of instruction set report.
  	 */
	public  void setInstructionSetReportStatus(boolean instructRep){
		InstructionSetReportStatus=instructRep;
	}
//-------------------------------------------------------------------------------------------
//Text IO
	
	/**
	 * Method which enables or disables the Text I/O 
	 * Log
	 */
	
	public void setTextIOLogStatus(boolean Text){
		isTextIOEnabled=Text;
	}
	
//-------------------------------------------------------------------------------------------
//Permanent Storage
	
	/**
	 * Method which sets the speed of the permanent storage
	 */
	public void setPermanentStorageSpeed(int PSSpeed){
		PermanentStorageSpeed = PSSpeed;
	}
	
	/**
	 * Method which sets the capacity of the permanent storage
	 */
	public void setPermanentStorageCapacity(int PSCap){
		PermanentStorageCapacity = PSCap;
	}
//-------------------------------------------------------------------------------------------
//Instruction Set
	
	/**
	 * Method which sets the speed of the instruction set
	 */
	public void setInstructionSetSpeed(int ISSpeed){
		InstructionSetSpeed = ISSpeed;
	}
	
	/**
	 * Method which sets the type of the instruction set
	 */
	public void setInstructionSetType(int ISType){
		InstructionSetType = ISType;
	}
}
